** compute correlations between alternative versions of gamma
global mainpath ".."

*load baseline gamma
import delimited "$mainpath\output\bluechip_rule_regressions.csv", clear 
gen Date=date(date, "YMD")
format Date %td
gen ym =mofd(Date)
lab var gamma_fe "Baseline gamma"

gsort ym
save "$mainpath/tmp/bluechip_rule_regressions.dta", replace

*load inertial gamma and rho
import delimited "$mainpath\output\bluechip_rule_inertial.csv", clear 
gen Date=date(date, "YMD")
format Date %td
gen ym =mofd(Date)

rename gamma gamma_inertia
lab var gamma_inertia "Gamma Inertial"
lab var rho "Rho"

gsort ym
save "$mainpath/tmp/bluechip_rule_inertial.dta", replace

*combine with other versions of gamma
*produced by Stata/gamma_ew.do
use "$mainpath\output\gamma_ew", clear
lab var gamma_ew "Forecaster-by-Forecaster"
drop _merge
merge 1:1 ym using "$mainpath/tmp/bluechip_rule_inertial.dta"
drop _merge
*produced by Stata/bias_v4.do
merge 1:1 ym using "$mainpath/output/gamma_bias_adjusted.dta"
lab var gamma_ffe_bias_adj_c14_high_root "Bias-Adjusted"
drop _merge
*produced by Stata/heterogeneity_FE_terciles.do
merge 1:1 ym using "$mainpath/output/coeffs_id_ym_interact.dta"
drop _merge
lab var gamma_id_ym_interact "Interaction FE"
*produced by Stata/heterogeneity_FE_terciles.do
merge 1:1 ym using "$mainpath/output/gamma_tercile1.dta"
drop _merge
lab var gamma_tercile1 "Inflation Tercile 1"
merge 1:1 ym using "$mainpath/output/gamma_tercile2.dta"
drop _merge
lab var gamma_tercile2 "Inflation Tercile 2"
merge 1:1 ym using "$mainpath/output/gamma_tercile3.dta"
drop _merge
lab var gamma_tercile3 "Inflation Tercile 3"


merge 1:1 ym using "$mainpath/tmp/bluechip_rule_regressions.dta"
drop _merge
graph twoway (line gamma_fe gamma_ew ym, yaxis(1))(line gamma_id_ym_interact ym, yaxis(2))
graph export "$mainpath\figures\AppendixFigureB2_PanelA.pdf", as(pdf) name("Graph") replace
pwcorr gamma_fe gamma_ew gamma_id_ym_interact

graph twoway line gamma_fe gamma_ffe_bias_adj_c14_high_root ym
graph export "$mainpath\figures\AppendixFigureB3.pdf", as(pdf) name("Graph") replace
pwcorr gamma_fe gamma_ffe_bias_adj_c14_high_root

graph twoway line gamma_tercile1 gamma_tercile2 gamma_tercile3 ym
graph export "$mainpath\figures\AppendixFigureB2_PanelB.pdf", as(pdf) name("Graph") replace
pwcorr gamma_fe gamma_tercile1 gamma_tercile1 gamma_tercile2 gamma_tercile3